<html>
<head><meta charset="utf-8"><title>Field resolution in hir_ty · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html">Field resolution in hir_ty</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="233335771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233335771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233335771">(Apr 06 2021 at 15:07)</a>:</h4>
<p>I'm looking at </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="sd">/// For each field in record literal, records the field it resolves to.</span>
<span class="w">    </span><span class="n">record_field_resolutions</span>: <span class="nc">FxHashMap</span><span class="o">&lt;</span><span class="n">ExprId</span><span class="p">,</span><span class="w"> </span><span class="n">FieldId</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
</code></pre></div>
<p>in <code>InferenceResult</code> and I'm not sure why this is stored in the inference result. Don't we know the full set of fields when we know the struct or enum variant that is being constructed?</p>



<a name="233336604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233336604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233336604">(Apr 06 2021 at 15:10)</a>:</h4>
<p>hmm. resolving the variant itself also currently happens during inference, but for both I think there's currently nothing that really requires inference</p>



<a name="233336766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233336766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233336766">(Apr 06 2021 at 15:10)</a>:</h4>
<p>ah although, not sure if associated types need to be resolved there? we don't do that currently, but there's a fixme there</p>



<a name="233337247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233337247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233337247">(Apr 06 2021 at 15:12)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=7a862a22ff0344b0613ca0c163e2a2e8">yeah...</a></p>



<a name="233338832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233338832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233338832">(Apr 06 2021 at 15:19)</a>:</h4>
<p>yeah, I was expecting that part to happen in hir_ty</p>



<a name="233338865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233338865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233338865">(Apr 06 2021 at 15:19)</a>:</h4>
<p>but not resolving individual fields</p>



<a name="233339119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233339119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233339119">(Apr 06 2021 at 15:20)</a>:</h4>
<p>we could instead change that map to record the <code>VariantId</code> for each <code>Expr::RecordLit</code></p>



<a name="233339166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233339166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233339166">(Apr 06 2021 at 15:21)</a>:</h4>
<p>that should slightly reduce memory usage and lets me play around with how we represent field shorthand syntax</p>



<a name="233339379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233339379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233339379">(Apr 06 2021 at 15:22)</a>:</h4>
<p>oh, yeah ok, that should be fine</p>



<a name="233339841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233339841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233339841">(Apr 06 2021 at 15:24)</a>:</h4>
<p>oh wait that's already stored</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="sd">/// For each struct literal, records the variant it resolves to.</span>
<span class="w">    </span><span class="n">variant_resolutions</span>: <span class="nc">FxHashMap</span><span class="o">&lt;</span><span class="n">ExprOrPatId</span><span class="p">,</span><span class="w"> </span><span class="n">VariantId</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
</code></pre></div>



<a name="233345479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233345479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233345479">(Apr 06 2021 at 15:59)</a>:</h4>
<p>opened <a href="https://github.com/rust-analyzer/rust-analyzer/pull/8376">https://github.com/rust-analyzer/rust-analyzer/pull/8376</a> to remove it</p>



<a name="233345504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233345504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233345504">(Apr 06 2021 at 16:00)</a>:</h4>
<p>I wonder if we should remove <code>record_pat_field_resolutions</code> too</p>



<a name="233347464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233347464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233347464">(Apr 06 2021 at 16:12)</a>:</h4>
<p>that would make sense then I think</p>



<a name="233347603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233347603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233347603">(Apr 06 2021 at 16:13)</a>:</h4>
<p>though I guess I just turned O(1) lookup into O(n) search over all fields, I kinda expect that to become a problem for people that use structs with thousands of fields</p>



<a name="233348724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233348724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233348724">(Apr 06 2021 at 16:21)</a>:</h4>
<p>huh</p>



<a name="233348747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233348747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233348747">(Apr 06 2021 at 16:21)</a>:</h4>
<p>something regressed <code>benchmark_syntax_highlighting_long_struct</code> a bunch</p>



<a name="233348979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233348979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233348979">(Apr 06 2021 at 16:22)</a>:</h4>
<p>1000 fields, yeah, that'd do it</p>



<a name="233349001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233349001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233349001">(Apr 06 2021 at 16:23)</a>:</h4>
<div class="codehilite"><pre><span></span><code>19:21:34|~/projects/rust-analyzer|HEAD⚡*
λ git rev-parse HEAD
61f15b72ac52c23148038b3867198597b345e2f6

19:21:38|~/projects/rust-analyzer|HEAD⚡*
λ cargo test -q --package ide --lib -- syntax_highlighting::tests::benchmark_syntax_highlighting_long_struct --exact --nocapture

running 1 test
syntax highlighting long struct: 904.13ms, 4161minstr
.
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 437 filtered out; finished in 0.93s

19:21:55|~/projects/rust-analyzer|HEAD✓
λ git switch master
Previous HEAD position was 61f15b72a Add parsing benchmark
Switched to branch &#39;master&#39;
Your branch is up to date with &#39;upstream/master&#39;.

19:21:56|~/projects/rust-analyzer|master✓
λ git rev-parse HEAD
7dd7017547c83bb3d33a785047e6da0a1464c0ad

19:22:00|~/projects/rust-analyzer|master✓
λ cargo test -q --package ide --lib -- syntax_highlighting::tests::benchmark_syntax_highlighting_long_struct --exact --nocapture

running 1 test
syntax highlighting long struct: 34.23s, 116ginstr
.
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 525 filtered out; finished in 34.27s
</code></pre></div>



<a name="233349071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233349071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233349071">(Apr 06 2021 at 16:23)</a>:</h4>
<p>so this does need to be cached, but <code>InferenceResult</code> is the wrong location for that</p>



<a name="233349102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233349102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233349102">(Apr 06 2021 at 16:24)</a>:</h4>
<p>I wonder if that was me actually..... I remember touching something about fields not so long ago. I don't think <span class="user-mention" data-user-id="211727">@Jonas Schievink  [he/him]</span> PR is the culprit though.</p>



<a name="233349159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233349159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233349159">(Apr 06 2021 at 16:24)</a>:</h4>
<p>oh okay, I thought this <em>just</em> happened</p>



<a name="233349329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233349329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233349329">(Apr 06 2021 at 16:25)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/issues/8377">https://github.com/rust-analyzer/rust-analyzer/issues/8377</a></p>



<a name="233349488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233349488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233349488">(Apr 06 2021 at 16:26)</a>:</h4>
<p>I didn't bisect this properly,  it might have happend just now? I am out of my quant for rust-analyzer for today, won't be able to come back to this until the next week. <span class="user-mention" data-user-id="211727">@Jonas Schievink  [he/him]</span> would you like to take a look?</p>



<a name="233349952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233349952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233349952">(Apr 06 2021 at 16:29)</a>:</h4>
<p>38.18s before my PR, 39.81s after, I guess that didn't cause it</p>



<a name="233350198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233350198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233350198">(Apr 06 2021 at 16:31)</a>:</h4>
<p>900ms after <a href="https://github.com/rust-analyzer/rust-analyzer/commit/f7156cb0aeaba8fe32c381a2d676b35d2c86f46f">https://github.com/rust-analyzer/rust-analyzer/commit/f7156cb0aeaba8fe32c381a2d676b35d2c86f46f</a> so it isn't me either :P</p>



<a name="233364255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233364255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233364255">(Apr 06 2021 at 18:14)</a>:</h4>
<p>Hmm, I don't understand how <a href="https://github.com/rust-analyzer/rust-analyzer/commit/636de3c709a7c86a1d3a870dc5dc3566310e9d92">https://github.com/rust-analyzer/rust-analyzer/commit/636de3c709a7c86a1d3a870dc5dc3566310e9d92</a> has caused this. It must be because of the doc comments on the 1000 fields, but after that commit we still use <code>field_attrs</code> to cache them, just like before.</p>



<a name="233367332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233367332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233367332">(Apr 06 2021 at 18:34)</a>:</h4>
<p><code>rowan::cursor::NodeData::next_sibling_or_token</code> is pretty high up in the profile, around 14%</p>



<a name="233369524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233369524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233369524">(Apr 06 2021 at 18:49)</a>:</h4>
<p>oh, we do call <code>source_map</code> from that benchmark</p>



<a name="233369779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233369779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233369779">(Apr 06 2021 at 18:50)</a>:</h4>
<p>so we end up calling <code>field.parent.child_source()</code> for every field, which is O(n²)</p>



<a name="233370303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233370303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233370303">(Apr 06 2021 at 18:54)</a>:</h4>
<p>ah, and before that commit I think we never even computed it for fields at all</p>



<a name="233370423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233370423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233370423">(Apr 06 2021 at 18:55)</a>:</h4>
<p>ah, no, that's not true, we did</p>



<a name="233371150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233371150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233371150">(Apr 06 2021 at 19:00)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/pull/8384">https://github.com/rust-analyzer/rust-analyzer/pull/8384</a> -- a draft of the test for this.</p>



<a name="233371213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233371213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233371213">(Apr 06 2021 at 19:01)</a>:</h4>
<p>We are now using machine learning in rust-analyzer (linear regression is clearly ML)</p>



<a name="233374259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233374259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233374259">(Apr 06 2021 at 19:23)</a>:</h4>
<p>I guess to fix the issue we can use the same trick as <code>variants_attrs</code> and <code>fields_attrs</code>, just for the source map</p>



<a name="233381303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233381303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233381303">(Apr 06 2021 at 20:14)</a>:</h4>
<p>After that it seems to finish in 2.52s (now in O(n log m) due to <code>AstPtr</code> conversion)</p>



<a name="233383691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/233383691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#233383691">(Apr 06 2021 at 20:32)</a>:</h4>
<p>(I'd love to see these benchmarks tracked in the metrics)</p>



<a name="235658874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Field%20resolution%20in%20hir_ty/near/235658874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Field.20resolution.20in.20hir_ty.html#235658874">(Apr 22 2021 at 11:23)</a>:</h4>
<p>linear plot-twist: I am now reviewing this code: <a href="https://github.com/near/nearcore/pull/4231/files#r618276633">https://github.com/near/nearcore/pull/4231/files#r618276633</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>